package com.kfm.login.model.response;

import lombok.Data;

@Data
public class Result {

    private String msg;
    private int code;
    private Object data;

    private Result(String msg, int code, Object data) {
        this.msg = msg;
        this.code = code;
        this.data = data;
    }

    private static final int SUCCESS_CODE = 1;
    private static final int ERROR_CODE = 0;

    public static Result success() {
        return success("成功", SUCCESS_CODE, null);
    }
    public static Result success(Object data) {
        return success("成功", SUCCESS_CODE, data);
    }

    public static Result success(String msg, Object data) {
        return success(msg, SUCCESS_CODE, data);
    }

    public static Result success(String msg, int code, Object data) {
        return new Result(msg, code, data);
    }

    public static Result failure(String msg) {
        return failure(msg, ERROR_CODE);
    }

    public static Result failure(String msg, int code) {
        return new Result(msg, code, null);
    }

}
